@echo off
chcp 65001 >nul
echo ========================================
echo Gradle 问题快速修复
echo ========================================
echo.

cd /d "%~dp0"

echo [步骤1] 停止所有Gradle进程...
taskkill /F /IM java.exe 2>nul
echo 完成
echo.

echo [步骤2] 删除Gradle缓存...
if exist ".gradle" (
    echo 删除 .gradle 目录...
    rmdir /s /q ".gradle"
)
if exist "app\.gradle" (
    echo 删除 app\.gradle 目录...
    rmdir /s /q "app\.gradle"
)
if exist "build" (
    echo 删除 build 目录...
    rmdir /s /q "build"
)
if exist "app\build" (
    echo 删除 app\build 目录...
    rmdir /s /q "app\build"
)
echo 完成
echo.

echo [步骤3] 删除本地缓存...
if exist "%USERPROFILE%\.gradle\caches" (
    echo 删除用户Gradle缓存...
    rmdir /s /q "%USERPROFILE%\.gradle\caches"
)
echo 完成
echo.

echo [步骤4] 重新同步Gradle...
call gradlew.bat --refresh-dependencies
echo.

echo ========================================
echo ✅ 修复完成！
echo ========================================
echo.
echo 现在请：
echo 1. 打开 Android Studio
echo 2. File -^> Sync Project with Gradle Files
echo 3. 等待同步完成
echo.
pause


